<?php
namespace App\Models;

use App\Models\Model;
use Admin;
use Illuminate\Support\Facades\Config;


class Issue extends Model
{

    protected $table = 'issue';

    public static function getIssueByTag($inputs)
    {
        $tag = Admin::tag();
        $issue = new issue();
        if (isSet($inputs['search']) && $inputs['search'])
        {
            $issue = $issue->where('question', 'LIKE', '%' . $inputs['search'] . '%');
        }
        if (isSet($inputs['course_id']) && $inputs['course_id'])
        {
            $issue = $issue->where('course_id', $inputs['course_id']);
        }
        //山姆后台 只加入消防
        if ($tag == 'visitor')
        {
            $issue = $issue->where('course_id', 86);
        } else if ($tag == 'guest')
        {
            $issue = $issue->where('course_id', '!=', 86);
        }
        return $pager = $issue->orderBy('id', 'DESC')->paginate();
    }

}
